<template>
	<view class="mall-cart-item">
		<text @click="sel" v-if="!item.sel" class="iconfont iconxuanzhongyuandian"></text>
		<text @click="sel" v-if="item.sel" class="iconfont iconxuanzhong"></text>
		<image class="img" :src="img"></image>
		<view class="goods-info">
			<text class="name">{{item.name}}</text>
			<text class="sku">规格：{{item.skuName?item.skuName:'默认'}}</text>
			<view class="edit">
				<text class="price">¥{{item.nowPrice}}</text>
				<num-edit @input="input" :value="item.number" class="num-edit"></num-edit>
			</view>
			
		</view>
		<view class="del" @click="del">
			<text class="iconfont iconcha"></text>
		</view>
	</view>
</template>

<script>
	import numEdit from '../base/num-edit/num-edit.vue'
	import CONFIG from '@/config/index.js'
	export default {
		components:{
			numEdit	
		},
		computed:{
				img(){
					return CONFIG.IMG_HEAD+this.item.img
				}
		},
		methods:{
			input(newVal){
				if(newVal<=0){
					this.del()
				}else{
					this.$emit("updateNum",newVal,this.index)
				}
			},
			del(){
				this.$emit("del",this.index)
			},
			sel(){
				this.$emit("sel",this.index)
			}
		},
		props:{
			item:Object,
			index:Number
		},
		data() {
			return {
				number:this.item.number
			};
		}
	}
</script>

<style lang="stylus">
	.mall-cart-item
		display flex
		align-items center
		height 264upx
		padding-right 22upx
		position relative
		background-color white
		border-bottom 1px solid #DCDCDC
		.iconxuanzhongyuandian,.iconxuanzhong
			color #B1B1B1
			font-size 34upx
			margin 0 16upx
		.img
			width:181upx;
			height:176upx;
			border-radius:10upx;
			margin-right 30upx
		.goods-info
			height 190upx
			flex 1
			display flex
			flex-direction column
			justify-content space-between
			overflow hidden
			padding-right 20upx
			.name
				margin-top 15upx
				font-size 24upx
				color #4E3D07
				text-overflow ellipsis
			.sku
				color #A1A1A1
				font-size 22upx
				padding 14upx 17upx
				background-color #FBFAFA
				border-radius 5upx
			.edit
				display flex
				align-items center
				justify-content space-between
				.price
					font-size 24upx
				. num-edit
					width 20upx
					
		.del
			color #B1B1B1
			height 181upx
			.iconcha
				font-size 22upx
				
			
			
</style>
